{layout name="layout" /}
<div class="hide row">
    <div class="col-xs-2">
        <a href="{:url('login')}" class=" btn " style="color: grey">返回</a>
    </div>
</div>
<div class="row">
<div class="col-xs-12 col-md-5 col-md-offset-6 m-t-md">        
    <form class="form-horizontal"  action="{:url('');}"  method="post">
        <div class="form-group">
            <label for="input_phone" class="col-sm-3 control-label">手机/邮箱</label>
            <div class="col-sm-9">
                <input name="phone" type="phone" class="form-control" id="input_phone" placeholder="手机/邮箱">
            </div>
        </div>
        <div class="form-group">
            <label for="input_password" class="col-sm-3 control-label">密码</label>
            <div class="col-sm-9">
                <input name="password" type="password" class="form-control" id="input_password" placeholder="密码">
            </div>
        </div>
        <div class="form-group dsp-nn">
            <div class="col-md-6 col-md-offset-6"><img id="captcha" src="{:url('member/captcha')}" alt="captcha"  />
            </div>
            <div class="col-md-6 col-md-offset-6 m-t-xs">
                <input name="captcha"  type="captcha" class="form-control" id="input_password" placeholder="验证码">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-9">
                <button id="submit" type="submit" class="btn btn-primary" style="width: 100%">注册</button>
            </div>
        </div>
    </form>
</div>
</div>
<script>
    $ (function ()
    {
        $(".header-title").html('注册');
        $("#captcha").on('click',function()
        {
           let img_src = $(this).attr('src')+"?seed="+Math.random; 
           $(this).attr('src',img_src);
        });

        $ ("#submit").on ('click', function (eve)
        {
            eve.preventDefault ();
            let url = $ ('form').attr ('action');
            let data = $('form').serialize();
            $.post (url, data, function (res)
            {
                $("#captcha").click();
                if (res.code)
                {
                    layer_tips(res.msg,function() {
                        location.href = "{:merge_url('member/login')}";
                    });
                }
                else
                {
                    layer_tips(res.msg);
                }
            });
        });
    });

</script>